package com.supermap.dataservice.cloud.chinatemplate;

import com.alibaba.dubbo.config.annotation.Service;
import com.supermap.dataservice.mysql.config.DynamicDataSourceContextHolder;
import com.supermap.dataservice.util.JSONUtil;
import com.supermap.dubbo.api.cloud.chinatemplate.ChinaTemplateService;
import org.apache.logging.log4j.util.Strings;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author aqua
 * @description
 * @date 2018年12月11 下午 7:04
 * @email 1301584033@qq.com
 */
@Service
public class ChinaTemplateImpl implements ChinaTemplateService {

    @Resource
    private ChinaTemplateMpper chinaTemplateMpper;
    @Override
    public JSONUtil getProductGrupByTemplateId(Integer areaCode, Integer templateId) {
        DynamicDataSourceContextHolder.setDataSourceKey("ds3");
        return new JSONUtil().setData(chinaTemplateMpper.getProductGrupByTemplateId(areaCode,templateId));
    }

    @Override
    public List<Map<String, Object>> getListProductTemplate(Integer areaCode) {

        DynamicDataSourceContextHolder.setDataSourceKey("ds3");
         if(areaCode != null)
        {
            return chinaTemplateMpper.getListProductTemplate(areaCode);
        }

        return null;
    }

    @Override
    public   List<Map<String,Object>>  getProduct(String productgroupId) {
        DynamicDataSourceContextHolder.setDataSourceKey("ds3");
        return chinaTemplateMpper.getProduct(productgroupId);
    }
}
